package com.pulaien.shop.controller;

import com.pulaien.common.core.controller.BaseController;
import com.pulaien.common.core.domain.AjaxResult;
import com.pulaien.system.service.IExchangeRateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 汇率Controller
 *
 * @author pulaien
 */
@RestController
@RequestMapping("/shop/rate")
@Api(tags = "商城端汇率", description = "汇率")
public class ShopExchangeRateController extends BaseController {
    @Autowired
    private IExchangeRateService exchangeRateService;

    /**
     * 获取日本汇率
     */
    @ApiOperation(value = "获取最新汇率")
    @GetMapping(value = "/getLatestRate")
    public AjaxResult getEnRate(HttpServletRequest request) {
        return success(exchangeRateService.getLatestRate());
    }


    @ApiOperation(value = "获取中日汇率")
    @GetMapping(value = "/getRate")
    public AjaxResult getRate(HttpServletRequest request) {
        return success(exchangeRateService.getRate());
    }

    @ApiOperation(value = "获取美元汇率")
    @GetMapping(value = "/getUSDRate")
    public AjaxResult getUSDRate(HttpServletRequest request) {
        return success(exchangeRateService.getUsdRate());
    }
}
